<?php

$user_id = $GLOBALS['user_id'];
$uid = $GLOBALS['uid'];

$user = new user($user_id);
$user_info[$user_id] = $user->load_tables('user_settings,user_stats,user_gladiator');

//echo government_setting('treasury_name');

// echo '<pre>';
// echo var_dump($user_info);
// echo '</pre>';

require($config['dir_inc'] . 'recaptcha.inc.php');

echo 'You have <B>'.$user_info[$user_id]['effort'].'</b> effort stored.<BR><BR>';

switch ($_REQUEST['function'])
{
    case 'get':
                if ($_REQUEST['v1'] == 1)
                {
                    echo '<b>To do what you want to do you have to put in some effort... each correct answer below will gain you 1 effort. When you want to use your new found effort and continue on in the game what you were originally hoping to then just click "<i>return to game</i>" below.';
                }
                    //echo 'effort building for <b>'.  $user_info[$user_id]['username'] . '</b>.<BR>';
                    $PHP_SELF = $_SERVER['REQUEST_URI'];
                    echo "<form action=\"$PHP_SELF\" name=\"recaptcha\" method=\"post\">";
                    // could add in roman numeral converter here if wanted
                            
                            
                            
                            # the response from reCAPTCHA
                            $resp = null;
                            # the error code from reCAPTCHA, if any
                            $error = null;
                            
                            # are we submitting the page?
                            if (@$_POST["submit"]) {
                              $resp = recaptcha_check_answer ($privatekey,
                                                              $_SERVER["REMOTE_ADDR"],
                                                              $_POST["recaptcha_challenge_field"],
                                                              $_POST["recaptcha_response_field"]);
                            
                              if ($resp->is_valid) {
                                    $sql = "UPDATE `user_stats` SET `effort`=`effort`+'1' WHERE `assoc_id`='$user_id'";
                                    if ($db->query($sql))
                                    {
											echo "<pre>Effort Gained! <br>-- <br>+1 effort stored</pre>";
									}
									else
									{
									echo $db->error;
									}
                              } else {
                                # set the error code so that we can display it. You could also use
                                # die ("reCAPTCHA failed"), but using the error message is
                                # more user friendly
                                $error = $resp->error;
											echo "<pre><font color=red>No Luck!</font> <br>-- <br>no energy gained</pre>";
                              }
                            }
                            echo recaptcha_get_html($GLOBALS['publickey'], $error);
                           echo "
                                <br/>
                                <input type=\"submit\" name=\"submit\" value=\"submit\" />
                                </form>";
                                if (strlen($user_info[$user_id]['page_before_effort']) > 0)
                                {
                                    $link = $config['url']['play_effort'] . $user_info[$user_id]['page_before_effort'];
                                    echo "<p align=center>[<a href=\"$link\">RETURN TO GAME</a>]</p>";
                                }
    break;
    default:
    
}


?>